package com.itheima.mq;

import com.itheima.service.OrderService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author ：yuanjian
 * @date ：Created in 2020/11/23 11:06
 * @description：
 */
@Component
public class DeleteOrder {

    @Resource
    private OrderService orderService;

    @RabbitListener(queues = "delOrder_queue")
    public void deleteOrder(String orderId){
        long id = Long.parseLong(orderId);
        Integer payStatus = orderService.selectPayStatusById(id);
        if(payStatus==0){
            System.out.println("删除订单");
            orderService.deleteOrderById(id);
        }
    }
}
